aboutsummaryrefslogtreecommitdiffstats
path: root/ScreenManager.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:20 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:20 +0200
commit85bb4ad9cb820ac3b8e935a930084a06cbfd2847 (patch)
tree681fd9b2d9fa80931b2a8bec4bb6667865b7c569 /ScreenManager.c
parentea859f50d9438bc61ae96721a4d255b49de78653 (diff)
downloaddebian_htop-85bb4ad9cb820ac3b8e935a930084a06cbfd2847.tar.gz
debian_htop-85bb4ad9cb820ac3b8e935a930084a06cbfd2847.tar.bz2
debian_htop-85bb4ad9cb820ac3b8e935a930084a06cbfd2847.zip
Imported Upstream version 0.6.3upstream/0.6.3
Diffstat (limited to 'ScreenManager.c')
-rw-r--r--ScreenManager.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/ScreenManager.c b/ScreenManager.c
index 28009ca..8e88e28 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -6,9 +6,9 @@ in the source distribution for its full text.
*/
#include "ScreenManager.h"
-#include "ListBox.h"
+#include "Panel.h"
#include "Object.h"
-#include "TypedVector.h"
+#include "Vector.h"
#include "FunctionBar.h"
#include "debug.h"
@@ -29,8 +29,8 @@ typedef struct ScreenManager_ {
int x2;
int y2;
Orientation orientation;
- TypedVector* items;
- TypedVector* fuBars;
+ Vector* items;
+ Vector* fuBars;
int itemCount;
FunctionBar* fuBar;
bool owner;
@@ -47,16 +47,16 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
this->y2 = y2;
this->fuBar = NULL;
this->orientation = orientation;
- this->items = TypedVector_new(LISTBOX_CLASS, owner, DEFAULT_SIZE);
- this->fuBars = TypedVector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE);
+ this->items = Vector_new(PANEL_CLASS, owner, DEFAULT_SIZE, NULL);
+ this->fuBars = Vector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE, NULL);
this->itemCount = 0;
this->owner = owner;
return this;
}
void ScreenManager_delete(ScreenManager* this) {
- TypedVector_delete(this->items);
- TypedVector_delete(this->fuBars);
+ Vector_delete(this->items);
+ Vector_delete(this->fuBars);
free(this);
}
@@ -64,38 +64,38 @@ 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*) TypedVector_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
- TypedVector_add(this->items, item);
+ Vector_add(this->items, item);
if (fuBar)
- TypedVector_add(this->fuBars, fuBar);
+ Vector_add(this->fuBars, fuBar);
else
- TypedVector_add(this->fuBars, FunctionBar_new(0, NULL, NULL, NULL));
+ Vector_add(this->fuBars, FunctionBar_new(0, NULL, NULL, NULL));
if (!this->fuBar && fuBar) this->fuBar = fuBar;
item->needsRedraw = true;
this->itemCount++;
}
-ListBox* ScreenManager_remove(ScreenManager* this, int index) {
+Panel* ScreenManager_remove(ScreenManager* this, int index) {
assert(this->itemCount > index);
- ListBox* lb = (ListBox*) TypedVector_remove(this->items, index);
- TypedVector_remove(this->fuBars, index);
+ Panel* panel = (Panel*) Vector_remove(this->items, index);
+ Vector_remove(this->fuBars, index);
this->fuBar = NULL;
this->itemCount--;
- return lb;
+ return panel;
}
void ScreenManager_setFunctionBar(ScreenManager* this, FunctionBar* fuBar) {
@@ -112,37 +112,37 @@ 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*) TypedVector_get(this->items, i);
- ListBox_resize(lb, lb->w, LINES-y1+y2);
- ListBox_move(lb, lastX, y1);
- lastX = lb->x + lb->w + 1;
+ Panel* panel = (Panel*) Vector_get(this->items, i);
+ Panel_resize(panel, panel->w, LINES-y1+y2);
+ Panel_move(panel, lastX, y1);
+ lastX = panel->x + panel->w + 1;
}
- ListBox* lb = (ListBox*) TypedVector_get(this->items, items-1);
- ListBox_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
- ListBox_move(lb, lastX, y1);
+ Panel* panel = (Panel*) Vector_get(this->items, items-1);
+ Panel_resize(panel, COLS-x1+x2-lastX, LINES-y1+y2);
+ Panel_move(panel, 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*) TypedVector_get(this->items, focus);
+ Panel* panelFocus = (Panel*) Vector_get(this->items, focus);
if (this->fuBar)
FunctionBar_draw(this->fuBar, NULL);
- int ch;
+ int ch = 0;
while (!quit) {
int items = this->itemCount;
for (int i = 0; i < items; i++) {
- ListBox* lb = (ListBox*) TypedVector_get(this->items, i);
- ListBox_draw(lb, i == focus);
+ Panel* panel = (Panel*) Vector_get(this->items, i);
+ Panel_draw(panel, i == focus);
if (i < items) {
if (this->orientation == HORIZONTAL) {
- mvvline(lb->y, lb->x+lb->w, ' ', lb->h+1);
+ mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1);
}
}
}
- FunctionBar* bar = (FunctionBar*) TypedVector_get(this->fuBars, focus);
+ FunctionBar* bar = (FunctionBar*) Vector_get(this->fuBars, focus);
if (bar)
this->fuBar = bar;
if (this->fuBar)
@@ -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*) TypedVector_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) {
+ Panel* panel = (Panel*) Vector_get(this->items, i);
+ if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
+ mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
focus = i;
- lbFocus = lb;
- ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
+ panelFocus = panel;
+ Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
loop = true;
break;
}
@@ -174,8 +174,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
}
if (loop) continue;
- if (lbFocus->eventHandler) {
- HandlerResult result = lbFocus->eventHandler(lbFocus, ch);
+ if (panelFocus->eventHandler) {
+ HandlerResult result = panelFocus->eventHandler(panelFocus, ch);
if (result == HANDLED) {
continue;
} else if (result == BREAK_LOOP) {
@@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
tryLeft:
if (focus > 0)
focus--;
- lbFocus = (ListBox*) TypedVector_get(this->items, focus);
- if (ListBox_getSize(lbFocus) == 0 && focus > 0)
+ panelFocus = (Panel*) Vector_get(this->items, focus);
+ if (Panel_getSize(panelFocus) == 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*) TypedVector_get(this->items, focus);
- if (ListBox_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
+ panelFocus = (Panel*) Vector_get(this->items, focus);
+ if (Panel_getSize(panelFocus) == 0 && focus < this->itemCount - 1)
goto tryRight;
break;
case KEY_F(10):
@@ -215,11 +215,11 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
quit = true;
continue;
default:
- ListBox_onKey(lbFocus, ch);
+ Panel_onKey(panelFocus, ch);
break;
}
}
- *lastFocus = lbFocus;
+ *lastFocus = panelFocus;
*lastKey = ch;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy