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