Commit c2cdcd0c authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Rename ListBox to Panel, matching dit.

parent a853faaa
#include "AvailableColumnsListBox.h"
#include "AvailableColumnsPanel.h"
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "ColumnsListBox.h"
#include "ColumnsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct AvailableColumnsListBox_ {
ListBox super;
ListBox* columns;
typedef struct AvailableColumnsPanel_ {
Panel super;
Panel* columns;
Settings* settings;
ScreenManager* scr;
} AvailableColumnsListBox;
} AvailableColumnsPanel;
}*/
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;
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;
this->settings = settings;
this->scr = scr;
super->eventHandler = AvailableColumnsListBox_eventHandler;
super->eventHandler = AvailableColumnsPanel_eventHandler;
ListBox_setHeader(super, "Available Columns");
Panel_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));
Panel_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);
void AvailableColumnsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
AvailableColumnsPanel* this = (AvailableColumnsPanel*) object;
Panel_done(super);
free(this);
}
HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
AvailableColumnsListBox* this = (AvailableColumnsListBox*) super;
char* text = ((ListItem*) ListBox_getSelected(super))->value;
HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
AvailableColumnsPanel* this = (AvailableColumnsPanel*) super;
char* text = ((ListItem*) Panel_getSelected(super))->value;
HandlerResult result = IGNORED;
switch(ch) {
......@@ -59,11 +59,11 @@ HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
case KEY_ENTER:
case KEY_F(5):
{
int at = ListBox_getSelectedIndex(this->columns) + 1;
if (at == ListBox_getSize(this->columns))
int at = Panel_getSelectedIndex(this->columns) + 1;
if (at == Panel_getSize(this->columns))
at--;
ListBox_insert(this->columns, at, (Object*) ListItem_new(text, 0));
ColumnsListBox_update(this->columns);
Panel_insert(this->columns, at, (Object*) ListItem_new(text, 0));
ColumnsPanel_update(this->columns);
result = HANDLED;
break;
}
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_AvailableColumnsListBox
#define HEADER_AvailableColumnsListBox
#ifndef HEADER_AvailableColumnsPanel
#define HEADER_AvailableColumnsPanel
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
typedef struct AvailableColumnsListBox_ {
ListBox super;
typedef struct AvailableColumnsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
ListBox* columns;
} AvailableColumnsListBox;
Panel* columns;
} AvailableColumnsPanel;
AvailableColumnsListBox* AvailableColumnsListBox_new(Settings* settings, ListBox* columns, ScreenManager* scr);
AvailableColumnsPanel* AvailableColumnsPanel_new(Settings* settings, Panel* columns, ScreenManager* scr);
void AvailableColumnsListBox_delete(Object* object);
void AvailableColumnsPanel_delete(Object* object);
HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch);
HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch);
#endif
#include "AvailableMetersListBox.h"
#include "AvailableMetersPanel.h"
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct AvailableMetersListBox_ {
ListBox super;
typedef struct AvailableMetersPanel_ {
Panel super;
Settings* settings;
ListBox* leftBox;
ListBox* rightBox;
Panel* leftBox;
Panel* rightBox;
ScreenManager* scr;
} AvailableMetersListBox;
} AvailableMetersPanel;
}*/
AvailableMetersListBox* AvailableMetersListBox_new(Settings* settings, ListBox* leftMeters, ListBox* rightMeters, ScreenManager* scr) {
AvailableMetersListBox* this = (AvailableMetersListBox*) malloc(sizeof(AvailableMetersListBox));
ListBox* super = (ListBox*) this;
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = AvailableMetersListBox_delete;
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr) {
AvailableMetersPanel* this = (AvailableMetersPanel*) malloc(sizeof(AvailableMetersPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = AvailableMetersPanel_delete;
this->settings = settings;
this->leftBox = leftMeters;
this->rightBox = rightMeters;
this->scr = scr;
super->eventHandler = AvailableMetersListBox_EventHandler;
super->eventHandler = AvailableMetersPanel_EventHandler;
ListBox_setHeader(super, "Available meters");
Panel_setHeader(super, "Available meters");
for (int i = 1; Meter_types[i]; i++) {
MeterType* type = Meter_types[i];
if (type != &CPUMeter) {
ListBox_add(super, (Object*) ListItem_new(type->uiName, i << 16));
Panel_add(super, (Object*) ListItem_new(type->uiName, i << 16));
}
}
MeterType* type = &CPUMeter;
int processors = settings->pl->processorCount;
if (processors > 1) {
ListBox_add(super, (Object*) ListItem_new("CPU average", 0));
Panel_add(super, (Object*) ListItem_new("CPU average", 0));
for (int i = 1; i <= processors; i++) {
char buffer[50];
sprintf(buffer, "%s %d", type->uiName, i);
ListBox_add(super, (Object*) ListItem_new(buffer, i));
Panel_add(super, (Object*) ListItem_new(buffer, i));
}
} else {
ListBox_add(super, (Object*) ListItem_new("CPU", 1));
Panel_add(super, (Object*) ListItem_new("CPU", 1));
}
return this;
}
void AvailableMetersListBox_delete(Object* object) {
ListBox* super = (ListBox*) object;
AvailableMetersListBox* this = (AvailableMetersListBox*) object;
ListBox_done(super);
void AvailableMetersPanel_delete(Object* object) {
Panel* super = (Panel*) object;
AvailableMetersPanel* this = (AvailableMetersPanel*) object;
Panel_done(super);
free(this);
}
/* private */
inline void AvailableMetersListBox_addHeader(Header* header, ListBox* lb, MeterType* type, int param, HeaderSide side) {
inline void AvailableMetersPanel_addHeader(Header* header, Panel* lb, MeterType* type, int param, HeaderSide side) {
Meter* meter = (Meter*) Header_addMeter(header, type, param, side);
ListBox_add(lb, (Object*) Meter_toListItem(meter));
Panel_add(lb, (Object*) Meter_toListItem(meter));
}
HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
AvailableMetersListBox* this = (AvailableMetersListBox*) super;
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
AvailableMetersPanel* this = (AvailableMetersPanel*) super;
Header* header = this->settings->header;
ListItem* selected = (ListItem*) ListBox_getSelected(super);
ListItem* selected = (ListItem*) Panel_getSelected(super);
int param = selected->key & 0xff;
int type = selected->key >> 16;
HandlerResult result = IGNORED;
......@@ -83,7 +83,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
case 'l':
case 'L':
{
AvailableMetersListBox_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER);
AvailableMetersPanel_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER);
result = HANDLED;
break;
}
......@@ -91,7 +91,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
case 'r':
case 'R':
{
AvailableMetersListBox_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER);
AvailableMetersPanel_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER);
result = HANDLED;
break;
}
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_AvailableMetersListBox
#define HEADER_AvailableMetersListBox
#ifndef HEADER_AvailableMetersPanel
#define HEADER_AvailableMetersPanel
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
typedef struct AvailableMetersListBox_ {
ListBox super;
typedef struct AvailableMetersPanel_ {
Panel super;
Settings* settings;
ListBox* leftBox;
ListBox* rightBox;
Panel* leftBox;
Panel* rightBox;
ScreenManager* scr;
} AvailableMetersListBox;
} AvailableMetersPanel;
AvailableMetersListBox* AvailableMetersListBox_new(Settings* settings, ListBox* leftMeters, ListBox* rightMeters, ScreenManager* scr);
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr);
void AvailableMetersListBox_delete(Object* object);
void AvailableMetersPanel_delete(Object* object);
HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch);
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch);
#endif
#include "CategoriesListBox.h"
#include "AvailableMetersListBox.h"
#include "MetersListBox.h"
#include "DisplayOptionsListBox.h"
#include "ColumnsListBox.h"
#include "ColorsListBox.h"
#include "AvailableColumnsListBox.h"
#include "CategoriesPanel.h"
#include "AvailableMetersPanel.h"
#include "MetersPanel.h"
#include "DisplayOptionsPanel.h"
#include "ColumnsPanel.h"
#include "ColorsPanel.h"
#include "AvailableColumnsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct CategoriesListBox_ {
ListBox super;
typedef struct CategoriesPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} CategoriesListBox;
} CategoriesPanel;
}*/
......@@ -41,36 +41,36 @@ char* ColorsFunctions[10] = {" ", " ", " ", " ", " ", "
/* private property */
char* AvailableColumnsFunctions[10] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done "};
CategoriesListBox* CategoriesListBox_new(Settings* settings, ScreenManager* scr) {
CategoriesListBox* this = (CategoriesListBox*) malloc(sizeof(CategoriesListBox));
ListBox* super = (ListBox*) this;
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = CategoriesListBox_delete;
CategoriesPanel* CategoriesPanel_new(Settings* settings, ScreenManager* scr) {
CategoriesPanel* this = (CategoriesPanel*) malloc(sizeof(CategoriesPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = CategoriesPanel_delete;
this->settings = settings;
this->scr = scr;
super->eventHandler = CategoriesListBox_eventHandler;
ListBox_setHeader(super, "Setup");
ListBox_add(super, (Object*) ListItem_new("Meters", 0));
ListBox_add(super, (Object*) ListItem_new("Display options", 0));
ListBox_add(super, (Object*) ListItem_new("Colors", 0));
ListBox_add(super, (Object*) ListItem_new("Columns", 0));
super->eventHandler = CategoriesPanel_eventHandler;
Panel_setHeader(super, "Setup");
Panel_add(super, (Object*) ListItem_new("Meters", 0));
Panel_add(super, (Object*) ListItem_new("Display options", 0));
Panel_add(super, (Object*) ListItem_new("Colors", 0));
Panel_add(super, (Object*) ListItem_new("Columns", 0));
return this;
}
void CategoriesListBox_delete(Object* object) {
ListBox* super = (ListBox*) object;
CategoriesListBox* this = (CategoriesListBox*) object;
ListBox_done(super);
void CategoriesPanel_delete(Object* object) {
Panel* super = (Panel*) object;
CategoriesPanel* this = (CategoriesPanel*) object;
Panel_done(super);
free(this);
}
HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
CategoriesListBox* this = (CategoriesListBox*) super;
HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
CategoriesPanel* this = (CategoriesPanel*) super;
HandlerResult result = IGNORED;
int previous = ListBox_getSelectedIndex(super);
int previous = Panel_getSelectedIndex(super);
switch (ch) {
case KEY_UP:
......@@ -79,24 +79,24 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
case KEY_PPAGE:
case KEY_HOME:
case KEY_END: {
ListBox_onKey(super, ch);
int selected = ListBox_getSelectedIndex(super);
Panel_onKey(super, ch);
int selected = Panel_getSelectedIndex(super);
if (previous != selected) {
int size = ScreenManager_size(this->scr);
for (int i = 1; i < size; i++)
ScreenManager_remove(this->scr, 1);
switch (selected) {
case 0:
CategoriesListBox_makeMetersPage(this);
CategoriesPanel_makeMetersPage(this);
break;
case 1:
CategoriesListBox_makeDisplayOptionsPage(this);
CategoriesPanel_makeDisplayOptionsPage(this);
break;
case 2:
CategoriesListBox_makeColorsPage(this);
CategoriesPanel_makeColorsPage(this);
break;
case 3:
CategoriesListBox_makeColumnsPage(this);
CategoriesPanel_makeColumnsPage(this);
break;
}
}
......@@ -107,28 +107,28 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
return result;
}
void CategoriesListBox_makeMetersPage(CategoriesListBox* this) {
ListBox* lbLeftMeters = (ListBox*) MetersListBox_new(this->settings, "Left column", this->settings->header->leftMeters, this->scr);
ListBox* lbRightMeters = (ListBox*) MetersListBox_new(this->settings, "Right column", this->settings->header->rightMeters, this->scr);
ListBox* lbAvailableMeters = (ListBox*) AvailableMetersListBox_new(this->settings, lbLeftMeters, lbRightMeters, this->scr);
void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
Panel* lbLeftMeters = (Panel*) MetersPanel_new(this->settings, "Left column", this->settings->header->leftMeters, this->scr);
Panel* lbRightMeters = (Panel*) MetersPanel_new(this->settings, "Right column", this->settings->header->rightMeters, this->scr);
Panel* lbAvailableMeters = (Panel*) AvailableMetersPanel_new(this->settings, lbLeftMeters, lbRightMeters, this->scr);
ScreenManager_add(this->scr, lbLeftMeters, FunctionBar_new(10, MetersFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, lbRightMeters, FunctionBar_new(10, MetersFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, lbAvailableMeters, FunctionBar_new(10, AvailableMetersFunctions, NULL, NULL), -1);
}
void CategoriesListBox_makeDisplayOptionsPage(CategoriesListBox* this) {
ListBox* lbDisplayOptions = (ListBox*) DisplayOptionsListBox_new(this->settings, this->scr);
void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) {
Panel* lbDisplayOptions = (Panel*) DisplayOptionsPanel_new(this->settings, this->scr);
ScreenManager_add(this->scr, lbDisplayOptions, FunctionBar_new(10, DisplayOptionsFunctions, NULL, NULL), -1);
}
void CategoriesListBox_makeColorsPage(CategoriesListBox* this) {
ListBox* lbColors = (ListBox*) ColorsListBox_new(this->settings, this->scr);
void CategoriesPanel_makeColorsPage(CategoriesPanel* this) {
Panel* lbColors = (Panel*) ColorsPanel_new(this->settings, this->scr);
ScreenManager_add(this->scr, lbColors, FunctionBar_new(10, ColorsFunctions, NULL, NULL), -1);
}
void CategoriesListBox_makeColumnsPage(CategoriesListBox* this) {
ListBox* lbColumns = (ListBox*) ColumnsListBox_new(this->settings, this->scr);
ListBox* lbAvailableColumns = (ListBox*) AvailableColumnsListBox_new(this->settings, lbColumns, this->scr);
void CategoriesPanel_makeColumnsPage(CategoriesPanel* this) {
Panel* lbColumns = (Panel*) ColumnsPanel_new(this->settings, this->scr);
Panel* lbAvailableColumns = (Panel*) AvailableColumnsPanel_new(this->settings, lbColumns, this->scr);
ScreenManager_add(this->scr, lbColumns, FunctionBar_new(10, ColumnsFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, lbAvailableColumns, FunctionBar_new(10, AvailableColumnsFunctions, NULL, NULL), -1);
}
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_CategoriesListBox
#define HEADER_CategoriesListBox
#ifndef HEADER_CategoriesPanel
#define HEADER_CategoriesPanel
#include "AvailableMetersListBox.h"
#include "MetersListBox.h"
#include "DisplayOptionsListBox.h"
#include "AvailableMetersPanel.h"
#include "MetersPanel.h"
#include "DisplayOptionsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "debug.h"
#include <assert.h>
typedef struct CategoriesListBox_ {
ListBox super;
typedef struct CategoriesPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} CategoriesListBox;
} CategoriesPanel;
CategoriesListBox* CategoriesListBox_new(Settings* settings, ScreenManager* scr);
CategoriesPanel* CategoriesPanel_new(Settings* settings, ScreenManager* scr);
void CategoriesListBox_delete(Object* object);
void CategoriesPanel_delete(Object* object);
HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch);
HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch);
void CategoriesListBox_makeMetersPage(CategoriesListBox* this);
void CategoriesPanel_makeMetersPage(CategoriesPanel* this);
void CategoriesListBox_makeDisplayOptionsPage(CategoriesListBox* this);
void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this);
void CategoriesListBox_makeColorsPage(CategoriesListBox* this);
void CategoriesPanel_makeColorsPage(CategoriesPanel* this);
void CategoriesListBox_makeColumnsPage(CategoriesListBox* this);
void CategoriesPanel_makeColumnsPage(CategoriesPanel* this);
#endif
......@@ -137,7 +137,7 @@ What's new in version 0.4
* Clock and load average meters
(thanks to Marc Calahan)
* BUGFIX: numeric swap indicator was printing bogus value
* BUGFIX: internal fixes on ListBox widget
* BUGFIX: internal fixes on Panel widget
* Clear the bottom line when exiting
* Press "F3" during search to walk through the results
* Improved navigation on column configuration screen
......
#include "CRT.h"
#include "ColorsListBox.h"
#include "ColorsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -11,20 +11,20 @@
#include <assert.h>
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in ColorsListBox.h
// * Increment the size of bool check in ColorsPanel.h
// * Add the entry in the ColorSchemes array below in the file
// * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors
/*{
typedef struct ColorsListBox_ {
ListBox super;
typedef struct ColorsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
bool check[5];
} ColorsListBox;
} ColorsPanel;
}*/
......@@ -39,37 +39,37 @@ static char* ColorSchemes[] = {
NULL
};
ColorsListBox* ColorsListBox_new(Settings* settings, ScreenManager* scr) {
ColorsListBox* this = (ColorsListBox*) malloc(sizeof(ColorsListBox));
ListBox* super = (ListBox*) this;
ListBox_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
((Object*)this)->delete = ColorsListBox_delete;
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
ColorsPanel* this = (ColorsPanel*) malloc(sizeof(ColorsPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
((Object*)this)->delete = ColorsPanel_delete;
this->settings = settings;
this->scr = scr;
super->eventHandler = ColorsListBox_EventHandler;
super->eventHandler = ColorsPanel_EventHandler;
ListBox_setHeader(super, "Colors");
Panel_setHeader(super, "Colors");
for (int i = 0; ColorSchemes[i] != NULL; i++) {
ListBox_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), &(this->check[i])));
Panel_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), &(this->check[i])));
this->check[i] = false;
}
this->check[settings->colorScheme] = true;
return this;
}
void ColorsListBox_delete(Object* object) {
ListBox* super = (ListBox*) object;
ColorsListBox* this = (ColorsListBox*) object;
ListBox_done(super);
void ColorsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
ColorsPanel* this = (ColorsPanel*) object;
Panel_done(super);
free(this);
}
HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch) {
ColorsListBox* this = (ColorsListBox*) super;
HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
ColorsPanel* this = (ColorsPanel*) super;
HandlerResult result = IGNORED;
int mark = ListBox_getSelectedIndex(super);
int mark = Panel_getSelectedIndex(super);
switch(ch) {
case 0x0a:
......@@ -88,7 +88,7 @@ HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch) {
this->settings->changed = true;
Header* header = this->settings->header;
CRT_setColors(mark);
ListBox* lbMenu = (ListBox*) Vector_get(this->scr->items, 0);
Panel* lbMenu = (Panel*) Vector_get(this->scr->items, 0);
Header_draw(header);
RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);
RichString_setAttr(&(lbMenu->header), CRT_colors[PANEL_HEADER_UNFOCUS]);
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_ColorsListBox
#define HEADER_ColorsListBox
#ifndef HEADER_ColorsPanel
#define HEADER_ColorsPanel
#include "ListBox.h"
#include "Panel.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -13,20 +13,20 @@
#include <assert.h>
typedef struct ColorsListBox_ {
ListBox super;
typedef struct ColorsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
bool check[5];
} ColorsListBox;
} ColorsPanel;
ColorsListBox* ColorsListBox_new(Settings* settings, ScreenManager* scr);
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr);
void ColorsListBox_delete(Object* object);
void ColorsPanel_delete(Object* object);
HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch);
HandlerResult ColorsPanel_EventHandler(Panel* super, int ch);
#endif
#include "ColumnsListBox.h"
#include "ColumnsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -10,49 +10,49 @@
/*{
typedef struct ColumnsListBox_ {
ListBox super;
typedef struct ColumnsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} ColumnsListBox;
} ColumnsPanel;
}*/
ColumnsListBox* ColumnsListBox_new(Settings* settings, ScreenManager* scr) {
ColumnsListBox* this = (ColumnsListBox*) malloc(sizeof(ColumnsListBox));
ListBox* super = (ListBox*) this;
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = ColumnsListBox_delete;
ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr) {
ColumnsPanel* this = (ColumnsPanel*) malloc(sizeof(ColumnsPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = ColumnsPanel_delete;
this->settings = settings;
this->scr = scr;
super->eventHandler = ColumnsListBox_eventHandler;
ListBox_setHeader(super, "Active Columns");
super->eventHandler = ColumnsPanel_eventHandler;
Panel_setHeader(super, "Active Columns");
ProcessField* fields = this->settings->pl->fields;
for (; *fields; fields++) {
ListBox_add(super, (Object*) ListItem_new(Process_fieldNames[*fields], 0));
Panel_add(super, (Object*) ListItem_new(Process_fieldNames[*fields], 0));
}
return this;
}
void ColumnsListBox_delete(Object* object) {
ListBox* super = (ListBox*) object;
ColumnsListBox* this = (ColumnsListBox*) object;
ListBox_done(super);
void ColumnsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
ColumnsPanel* this = (ColumnsPanel*) object;
Panel_done(super);
free(this);
}
void ColumnsListBox_update(ListBox* super) {
ColumnsListBox* this = (ColumnsListBox*) super;
int size = ListBox_getSize(super);
void ColumnsPanel_update(Panel* super) {
ColumnsPanel* this = (ColumnsPanel*) super;
int size = Panel_getSize(super);
this->settings->changed = true;
// FIXME: this is crappily inefficient
free(this->settings->pl->fields);
this->settings->pl->fields = (ProcessField*) malloc(sizeof(ProcessField) * (size+1));
for (int i = 0; i < size; i++) {
char* text = ((ListItem*) ListBox_get(super, i))->value;
char* text = ((ListItem*) Panel_get(super, i))->value;
for (int j = 1; j <= LAST_PROCESSFIELD; j++) {
if (String_eq(text, Process_fieldNames[j])) {
this->settings->pl->fields[i] = j;
......@@ -63,11 +63,11 @@ void ColumnsListBox_update(ListBox* super) {
this->settings->pl->fields[size] = 0;
}
HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
int selected = ListBox_getSelectedIndex(super);
int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED;
int size = ListBox_getSize(super);
int size = Panel_getSize(super);
switch(ch) {
case KEY_F(7):
......@@ -75,7 +75,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case '-':
{
if (selected < size - 1)
ListBox_moveSelectedUp(super);
Panel_moveSelectedUp(super);
result = HANDLED;
break;
}
......@@ -84,7 +84,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case '+':
{
if (selected < size - 2)
ListBox_moveSelectedDown(super);
Panel_moveSelectedDown(super);
result = HANDLED;
break;
}
......@@ -92,13 +92,13 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case KEY_DC:
{
if (selected < size - 1) {
ListBox_remove(super, selected);
Panel_remove(super, selected);
}
result = HANDLED;
break;
}
}
if (result == HANDLED)
ColumnsListBox_update(super);
ColumnsPanel_update(super);
return result;
}
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_ColumnsListBox
#define HEADER_ColumnsListBox
#ifndef HEADER_ColumnsPanel
#define HEADER_ColumnsPanel
#include "ListBox.h"
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -12,21 +12,21 @@
#include <assert.h>
typedef struct ColumnsListBox_ {
ListBox super;
typedef struct ColumnsPanel_ {
Panel super;
Settings* settings;
Vector* columns;
ScreenManager* scr;
} ColumnsListBox;
} ColumnsPanel;
ColumnsListBox* ColumnsListBox_new(Settings* settings, ScreenManager* scr);
ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
void ColumnsListBox_delete(Object* object);
void ColumnsPanel_delete(Object* object);
void ColumnsListBox_update(ListBox* super);
void ColumnsPanel_update(Panel* super);
HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch);
HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch);
#endif
#include "DisplayOptionsListBox.h"
#include "DisplayOptionsPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -11,48 +11,48 @@
/*{
typedef struct DisplayOptionsListBox_ {
ListBox super;
typedef struct DisplayOptionsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} DisplayOptionsListBox;
} DisplayOptionsPanel;
}*/
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;
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
DisplayOptionsPanel* this = (DisplayOptionsPanel*) malloc(sizeof(DisplayOptionsPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
((Object*)this)->delete = DisplayOptionsPanel_delete;
this->settings = settings;
this->scr = scr;
super->eventHandler = DisplayOptionsListBox_EventHandler;
super->eventHandler = DisplayOptionsPanel_EventHandler;
ListBox_setHeader(super, "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("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
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)));
Panel_setHeader(super, "Display options");
Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
Panel_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);
void DisplayOptionsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
Panel_done(super);
free(this);
}
HandlerResult DisplayOptionsListBox_EventHandler(ListBox* super, int ch) {
DisplayOptionsListBox* this = (DisplayOptionsListBox*) super;
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch) {
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
HandlerResult result = IGNORED;
CheckItem* selected = (CheckItem*) ListBox_getSelected(super);
CheckItem* selected = (CheckItem*) Panel_getSelected(super);
switch(ch) {
case 0x0a:
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_DisplayOptionsListBox
#define HEADER_DisplayOptionsListBox
#ifndef HEADER_DisplayOptionsPanel
#define HEADER_DisplayOptionsPanel
#include "ListBox.h"
#include "Panel.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -13,19 +13,19 @@
#include <assert.h>
typedef struct DisplayOptionsListBox_ {
ListBox super;
typedef struct DisplayOptionsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} DisplayOptionsListBox;
} DisplayOptionsPanel;
DisplayOptionsListBox* DisplayOptionsListBox_new(Settings* settings, ScreenManager* scr);
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr);
void DisplayOptionsListBox_delete(Object* object);
void DisplayOptionsPanel_delete(Object* object);
HandlerResult DisplayOptionsListBox_EventHandler(ListBox* super, int ch);
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch);
#endif
......@@ -10,22 +10,22 @@ pixmap_DATA = htop.png
AM_CFLAGS = -pedantic -Wall -std=c99
AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
htop_SOURCES = AvailableMetersListBox.c CategoriesListBox.c ClockMeter.c \
CPUMeter.c CRT.c DebugMemory.c DisplayOptionsListBox.c FunctionBar.c \
Hashtable.c Header.c htop.c ListBox.c ListItem.c LoadAverageMeter.c \
MemoryMeter.c Meter.c MetersListBox.c Object.c Process.c \
htop_SOURCES = AvailableMetersPanel.c CategoriesPanel.c ClockMeter.c \
CPUMeter.c CRT.c DebugMemory.c DisplayOptionsPanel.c FunctionBar.c \
Hashtable.c Header.c htop.c Panel.c ListItem.c LoadAverageMeter.c \
MemoryMeter.c Meter.c MetersPanel.c Object.c Process.c \
ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c \
SignalsListBox.c String.c SwapMeter.c TasksMeter.c Vector.c \
UptimeMeter.c UsersTable.c AvailableMetersListBox.h CategoriesListBox.h \
SignalsPanel.c String.c SwapMeter.c TasksMeter.c Vector.c \
UptimeMeter.c UsersTable.c AvailableMetersPanel.h CategoriesPanel.h \
ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h \
DisplayOptionsListBox.h FunctionBar.h Hashtable.h Header.h htop.h ListBox.h \
DisplayOptionsPanel.h FunctionBar.h Hashtable.h Header.h htop.h Panel.h \
ListItem.h LoadAverageMeter.h MemoryMeter.h Meter.h \
MetersListBox.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \
Settings.h SignalItem.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \
MetersPanel.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \
Settings.h SignalItem.h SignalsPanel.h String.h SwapMeter.h TasksMeter.h \
Vector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h \
ColorsListBox.c ColorsListBox.h TraceScreen.c TraceScreen.h \
AvailableColumnsListBox.c AvailableColumnsListBox.h ColumnsListBox.c \
ColumnsListBox.h
ColorsPanel.c ColorsPanel.h TraceScreen.c TraceScreen.h \
AvailableColumnsPanel.c AvailableColumnsPanel.h ColumnsPanel.c \
ColumnsPanel.h
debug:
$(MAKE) all CFLAGS="-g -DDEBUG"
#include "MetersListBox.h"
#include "MetersPanel.h"
#include "ListBox.h"
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -10,45 +10,45 @@
/*{
typedef struct MetersListBox_ {
ListBox super;
typedef struct MetersPanel_ {
Panel super;
Settings* settings;
Vector* meters;
ScreenManager* scr;
} MetersListBox;
} MetersPanel;
}*/
MetersListBox* MetersListBox_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr) {
MetersListBox* this = (MetersListBox*) malloc(sizeof(MetersListBox));
ListBox* super = (ListBox*) this;
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = MetersListBox_delete;
MetersPanel* MetersPanel_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr) {
MetersPanel* this = (MetersPanel*) malloc(sizeof(MetersPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
((Object*)this)->delete = MetersPanel_delete;
this->settings = settings;
this->meters = meters;
this->scr = scr;
super->eventHandler = MetersListBox_EventHandler;
ListBox_setHeader(super, header);
super->eventHandler = MetersPanel_EventHandler;
Panel_setHeader(super, header);
for (int i = 0; i < Vector_size(meters); i++) {
Meter* meter = (Meter*) Vector_get(meters, i);
ListBox_add(super, (Object*) Meter_toListItem(meter));
Panel_add(super, (Object*) Meter_toListItem(meter));
}
return this;
}
void MetersListBox_delete(Object* object) {
ListBox* super = (ListBox*) object;
MetersListBox* this = (MetersListBox*) object;
ListBox_done(super);
void MetersPanel_delete(Object* object) {
Panel* super = (Panel*) object;
MetersPanel* this = (MetersPanel*) object;
Panel_done(super);
free(this);
}
HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
MetersListBox* this = (MetersListBox*) super;
HandlerResult MetersPanel_EventHandler(Panel* super, int ch) {
MetersPanel* this = (MetersPanel*) super;
int selected = ListBox_getSelectedIndex(super);
int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED;
switch(ch) {
......@@ -62,7 +62,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
int mode = meter->mode + 1;
if (mode == LAST_METERMODE) mode = 1;
Meter_setMode(meter, mode);
ListBox_set(super, selected, (Object*) Meter_toListItem(meter));
Panel_set(super, selected, (Object*) Meter_toListItem(meter));
result = HANDLED;
break;
}
......@@ -71,7 +71,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
case '-':
{
Vector_moveUp(this->meters, selected);
ListBox_moveSelectedUp(super);
Panel_moveSelectedUp(super);
result = HANDLED;
break;
}
......@@ -80,7 +80,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
case '+':
{
Vector_moveDown(this->meters, selected);
ListBox_moveSelectedDown(super);
Panel_moveSelectedDown(super);
result = HANDLED;
break;
}
......@@ -89,7 +89,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
{
if (selected < Vector_size(this->meters)) {
Vector_remove(this->meters, selected);
ListBox_remove(super, selected);
Panel_remove(super, selected);
}
result = HANDLED;
break;
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_MetersListBox
#define HEADER_MetersListBox
#ifndef HEADER_MetersPanel
#define HEADER_MetersPanel
#include "ListBox.h"
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
......@@ -12,19 +12,19 @@
#include <assert.h>
typedef struct MetersListBox_ {
ListBox super;
typedef struct MetersPanel_ {
Panel super;
Settings* settings;
Vector* meters;
ScreenManager* scr;
} MetersListBox;
} MetersPanel;
MetersListBox* MetersListBox_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr);
MetersPanel* MetersPanel_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr);
void MetersListBox_delete(Object* object);
void MetersPanel_delete(Object* object);
HandlerResult MetersListBox_EventHandler(ListBox* super, int ch);
HandlerResult MetersPanel_EventHandler(Panel* super, int ch);
#endif
/*
htop - ListBox.c
htop - Panel.c
(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Object.h"
#include "ListBox.h"
#include "Panel.h"
#include "Vector.h"
#include "CRT.h"
#include "RichString.h"
......@@ -22,7 +22,7 @@ in the source distribution for its full text.
/*{
typedef struct ListBox_ ListBox;
typedef struct Panel_ Panel;
typedef enum HandlerResult_ {
HANDLED,
......@@ -30,9 +30,9 @@ typedef enum HandlerResult_ {
BREAK_LOOP
} HandlerResult;
typedef HandlerResult(*ListBox_EventHandler)(ListBox*, int);
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
struct ListBox_ {
struct Panel_ {
Object super;
int x, y, w, h;
WINDOW* window;
......@@ -42,10 +42,10 @@ struct ListBox_ {
int oldSelected;
bool needsRedraw;
RichString header;
ListBox_EventHandler eventHandler;
Panel_EventHandler eventHandler;
};
extern char* LISTBOX_CLASS;
extern char* PANEL_CLASS;
}*/
......@@ -57,25 +57,25 @@ extern char* LISTBOX_CLASS;
#endif
/* private property */
char* LISTBOX_CLASS = "ListBox";
char* PANEL_CLASS = "Panel";
ListBox* ListBox_new(int x, int y, int w, int h, char* type, bool owner) {
ListBox* this;
this = malloc(sizeof(ListBox));
ListBox_init(this, x, y, w, h, type, owner);
Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner) {
Panel* this;
this = malloc(sizeof(Panel));
Panel_init(this, x, y, w, h, type, owner);
return this;
}
void ListBox_delete(Object* cast) {
ListBox* this = (ListBox*)cast;
ListBox_done(this);
void Panel_delete(Object* cast) {
Panel* this = (Panel*)cast;
Panel_done(this);
free(this);
}
void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool owner) {
void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner) {
Object* super = (Object*) this;
super->class = LISTBOX_CLASS;
super->delete = ListBox_delete;
super->class = PANEL_CLASS;
super->delete = Panel_delete;
this->x = x;
this->y = y;
this->w = w;
......@@ -90,13 +90,13 @@ void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool ow
this->header.len = 0;
}
void ListBox_done(ListBox* this) {
void Panel_done(Panel* this) {
assert (this != NULL);
RichString_delete(this->header);
Vector_delete(this->items);
}
inline void ListBox_setRichHeader(ListBox* this, RichString header) {
inline void Panel_setRichHeader(Panel* this, RichString header) {
assert (this != NULL);
if (this->header.len > 0) {
......@@ -106,15 +106,15 @@ inline void ListBox_setRichHeader(ListBox* this, RichString header) {
this->needsRedraw = true;
}
inline void ListBox_setHeader(ListBox* this, char* header) {
ListBox_setRichHeader(this, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], header));
inline void Panel_setHeader(Panel* this, char* header) {
Panel_setRichHeader(this, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], header));
}
void ListBox_setEventHandler(ListBox* this, ListBox_EventHandler eh) {
void Panel_setEventHandler(Panel* this, Panel_EventHandler eh) {
this->eventHandler = eh;
}
void ListBox_move(ListBox* this, int x, int y) {
void Panel_move(Panel* this, int x, int y) {
assert (this != NULL);
this->x = x;
......@@ -122,7 +122,7 @@ void ListBox_move(ListBox* this, int x, int y) {
this->needsRedraw = true;
}
void ListBox_resize(ListBox* this, int w, int h) {
void Panel_resize(Panel* this, int w, int h) {
assert (this != NULL);
if (this->header.len > 0)
......@@ -132,7 +132,7 @@ void ListBox_resize(ListBox* this, int w, int h) {
this->needsRedraw = true;
}
void ListBox_prune(ListBox* this) {
void Panel_prune(Panel* this) {
assert (this != NULL);
Vector_prune(this->items);
......@@ -142,33 +142,33 @@ void ListBox_prune(ListBox* this) {
this->needsRedraw = true;
}
void ListBox_add(ListBox* this, Object* o) {
void Panel_add(Panel* this, Object* o) {
assert (this != NULL);
Vector_add(this->items, o);
this->needsRedraw = true;
}
void ListBox_insert(ListBox* this, int i, Object* o) {
void Panel_insert(Panel* this, int i, Object* o) {
assert (this != NULL);
Vector_insert(this->items, i, o);
this->needsRedraw = true;
}
void ListBox_set(ListBox* this, int i, Object* o) {
void Panel_set(Panel* this, int i, Object* o) {
assert (this != NULL);
Vector_set(this->items, i, o);
}
Object* ListBox_get(ListBox* this, int i) {
Object* Panel_get(Panel* this, int i) {
assert (this != NULL);
return Vector_get(this->items, i);
}
Object* ListBox_remove(ListBox* this, int i) {
Object* Panel_remove(Panel* this, int i) {
assert (this != NULL);
this->needsRedraw = true;
......@@ -178,13 +178,13 @@ Object* ListBox_remove(ListBox* this, int i) {
return removed;
}
Object* ListBox_getSelected(ListBox* this) {
Object* Panel_getSelected(Panel* this) {
assert (this != NULL);
return Vector_get(this->items, this->selected);
}
void ListBox_moveSelectedUp(ListBox* this) {
void Panel_moveSelectedUp(Panel* this) {
assert (this != NULL);
Vector_moveUp(this->items, this->selected);
......@@ -192,7 +192,7 @@ void ListBox_moveSelectedUp(ListBox* this) {
this->selected--;
}
void ListBox_moveSelectedDown(ListBox* this) {
void Panel_moveSelectedDown(Panel* this) {
assert (this != NULL);
Vector_moveDown(this->items, this->selected);
......@@ -200,26 +200,26 @@ void ListBox_moveSelectedDown(ListBox* this) {
this->selected++;
}
int ListBox_getSelectedIndex(ListBox* this) {
int Panel_getSelectedIndex(Panel* this) {
assert (this != NULL);
return this->selected;
}
int ListBox_getSize(ListBox* this) {
int Panel_getSize(Panel* this) {
assert (this != NULL);
return Vector_size(this->items);
}
void ListBox_setSelected(ListBox* this, int selected) {
void Panel_setSelected(Panel* this, int selected) {
assert (this != NULL);
selected = MAX(0, MIN(Vector_size(this->items) - 1, selected));
this->selected = selected;
}
void ListBox_draw(ListBox* this, bool focus) {
void Panel_draw(Panel* this, bool focus) {
assert (this != NULL);
int first, last;
......@@ -311,7 +311,7 @@ void ListBox_draw(ListBox* this, bool focus) {
move(0, 0);
}
void ListBox_onKey(ListBox* this, int key) {
void Panel_onKey(Panel* this, int key) {
assert (this != NULL);
switch (key) {
case KEY_DOWN:
......
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_ListBox
#define HEADER_ListBox
#ifndef HEADER_Panel
#define HEADER_Panel
/*
htop
(C) 2004-2006 Hisham H. Muhammad
......@@ -25,7 +25,7 @@ in the source distribution for its full text.
//#link curses
typedef struct ListBox_ ListBox;
typedef struct Panel_ Panel;
typedef enum HandlerResult_ {
HANDLED,
......@@ -33,9 +33,9 @@ typedef enum HandlerResult_ {
BREAK_LOOP
} HandlerResult;
typedef HandlerResult(*ListBox_EventHandler)(ListBox*, int);
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
struct ListBox_ {
struct Panel_ {
Object super;
int x, y, w, h;
WINDOW* window;
......@@ -45,57 +45,57 @@ struct ListBox_ {
int oldSelected;
bool needsRedraw;
RichString header;
ListBox_EventHandler eventHandler;
Panel_EventHandler eventHandler;
};
extern char* LISTBOX_CLASS;
extern char* PANEL_CLASS;
ListBox* ListBox_new(int x, int y, int w, int h, char* type, bool owner);
Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner);
void ListBox_delete(Object* cast);
void Panel_delete(Object* cast);
void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool owner);
void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner);
void ListBox_done(ListBox* this);
void Panel_done(Panel* this);
void ListBox_setEventHandler(ListBox* this, ListBox_EventHandler eh);
void Panel_setEventHandler(Panel* this, Panel_EventHandler eh);
void ListBox_setRichHeader(ListBox* this, RichString header);
void Panel_setRichHeader(Panel* this, RichString header);
void ListBox_setHeader(ListBox* this, char* header);
void Panel_setHeader(Panel* this, char* header);
void ListBox_move(ListBox* this, int x, int y);
void Panel_move(Panel* this, int x, int y);
void ListBox_resize(ListBox* this, int w, int h);
void Panel_resize(Panel* this, int w, int h);
void ListBox_prune(ListBox* this);
void Panel_prune(Panel* this);
void ListBox_add(ListBox* this, Object* o);
void Panel_add(Panel* this, Object* o);
void ListBox_insert(ListBox* this, int i, Object* o);
void Panel_insert(Panel* this, int i, Object* o);
void ListBox_set(ListBox* this, int i, Object* o);
void Panel_set(Panel* this, int i, Object* o);
Object* ListBox_get(ListBox* this, int i);
Object* Panel_get(Panel* this, int i);
Object* ListBox_remove(ListBox* this, int i);
Object* Panel_remove(Panel* this, int i);
Object* ListBox_getSelected(ListBox* this);
Object* Panel_getSelected(Panel* this);
void ListBox_moveSelectedUp(ListBox* this);
void Panel_moveSelectedUp(Panel* this);
void ListBox_moveSelectedDown(ListBox* this);
void Panel_moveSelectedDown(Panel* this);
int ListBox_getSelectedIndex(ListBox* this);
int Panel_getSelectedIndex(Panel* this);
int ListBox_getSize(ListBox* this);
int Panel_getSize(Panel* this);
void ListBox_setSelected(ListBox* this, int selected);
void Panel_setSelected(Panel* this, int selected);
void ListBox_draw(ListBox* this, bool focus);
void Panel_draw(Panel* this, bool focus);
void ListBox_onKey(ListBox* this, int key);
void Panel_onKey(Panel* this, int key);
#endif
......@@ -6,7 +6,7 @@ in the source distribution for its full text.
*/
#include "ScreenManager.h"
#include "ListBox.h"
#include "Panel.h"
#include "Object.h"
#include "Vector.h"
#include "FunctionBar.h"
......@@ -47,7 +47,7 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
this->y2 = y2;
this->fuBar = NULL;
this->orientation = orientation;
this->items = Vector_new(LISTBOX_CLASS, owner, DEFAULT_SIZE);
this->items = Vector_new(PANEL_CLASS, owner, DEFAULT_SIZE);
this->fuBars = Vector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE);
this->itemCount = 0;
this->owner = owner;
......@@ -64,19 +64,19 @@ inline int ScreenManager_size(ScreenManager* this) {
return this->itemCount;
}
void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, int size) {
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size) {
if (this->orientation == HORIZONTAL) {
int lastX = 0;
if (this->itemCount > 0) {
ListBox* last = (ListBox*) Vector_get(this->items, this->itemCount - 1);
Panel* last = (Panel*) Vector_get(this->items, this->itemCount - 1);
lastX = last->x + last->w + 1;
}
if (size > 0) {
ListBox_resize(item, size, LINES-this->y1+this->y2);
Panel_resize(item, size, LINES-this->y1+this->y2);
} else {
ListBox_resize(item, COLS-this->x1+this->x2-lastX, LINES-this->y1+this->y2);
Panel_resize(item, COLS-this->x1+this->x2-lastX, LINES-this->y1+this->y2);
}
ListBox_move(item, lastX, this->y1);
Panel_move(item, lastX, this->y1);
}
// TODO: VERTICAL
Vector_add(this->items, item);
......@@ -89,9 +89,9 @@ void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, i
this->itemCount++;
}
ListBox* ScreenManager_remove(ScreenManager* this, int index) {
Panel* ScreenManager_remove(ScreenManager* this, int index) {
assert(this->itemCount > index);
ListBox* lb = (ListBox*) Vector_remove(this->items, index);
Panel* lb = (Panel*) Vector_remove(this->items, index);
Vector_remove(this->fuBars, index);
this->fuBar = NULL;
this->itemCount--;
......@@ -112,21 +112,21 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
int items = this->itemCount;
int lastX = 0;
for (int i = 0; i < items - 1; i++) {
ListBox* lb = (ListBox*) Vector_get(this->items, i);
ListBox_resize(lb, lb->w, LINES-y1+y2);
ListBox_move(lb, lastX, y1);
Panel* lb = (Panel*) Vector_get(this->items, i);
Panel_resize(lb, lb->w, LINES-y1+y2);
Panel_move(lb, lastX, y1);
lastX = lb->x + lb->w + 1;
}
ListBox* lb = (ListBox*) Vector_get(this->items, items-1);
ListBox_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
ListBox_move(lb, lastX, y1);
Panel* lb = (Panel*) Vector_get(this->items, items-1);
Panel_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
Panel_move(lb, lastX, y1);
}
void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
bool quit = false;
int focus = 0;
ListBox* lbFocus = (ListBox*) Vector_get(this->items, focus);
Panel* lbFocus = (Panel*) Vector_get(this->items, focus);
if (this->fuBar)
FunctionBar_draw(this->fuBar, NULL);
......@@ -134,8 +134,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
while (!quit) {
int items = this->itemCount;
for (int i = 0; i < items; i++) {
ListBox* lb = (ListBox*) Vector_get(this->items, i);
ListBox_draw(lb, i == focus);
Panel* lb = (Panel*) Vector_get(this->items, i);
Panel_draw(lb, i == focus);
if (i < items) {
if (this->orientation == HORIZONTAL) {
mvvline(lb->y, lb->x+lb->w, ' ', lb->h+1);
......@@ -159,12 +159,12 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
} else {
for (int i = 0; i < this->itemCount; i++) {
ListBox* lb = (ListBox*) Vector_get(this->items, i);
Panel* lb = (Panel*) Vector_get(this->items, i);
if (mevent.x > lb->x && mevent.x <= lb->x+lb->w &&
mevent.y > lb->y && mevent.y <= lb->y+lb->h) {
focus = i;
lbFocus = lb;
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
loop = true;
break;
}
......@@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
tryLeft:
if (focus > 0)
focus--;
lbFocus = (ListBox*) Vector_get(this->items, focus);
if (ListBox_getSize(lbFocus) == 0 && focus > 0)
lbFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(lbFocus) == 0 && focus > 0)
goto tryLeft;
break;
case KEY_RIGHT:
......@@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
tryRight:
if (focus < this->itemCount - 1)
focus++;
lbFocus = (ListBox*) Vector_get(this->items, focus);
if (ListBox_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
lbFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
goto tryRight;
break;
case KEY_F(10):
......@@ -215,7 +215,7 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
quit = true;
continue;
default:
ListBox_onKey(lbFocus, ch);
Panel_onKey(lbFocus, ch);
break;
}
}
......
......@@ -9,7 +9,7 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "ListBox.h"
#include "Panel.h"
#include "Object.h"
#include "Vector.h"
#include "FunctionBar.h"
......@@ -45,14 +45,14 @@ void ScreenManager_delete(ScreenManager* this);
inline int ScreenManager_size(ScreenManager* this);
void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, int size);
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size);
ListBox* ScreenManager_remove(ScreenManager* this, int index);
Panel* ScreenManager_remove(ScreenManager* this, int index);
void ScreenManager_setFunctionBar(ScreenManager* this, FunctionBar* fuBar);
void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey);
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment